﻿using System;
using Wisdom.Core;

namespace Wisdom.Core
{
    /// <summary>
    /// 描述服务注册
    /// </summary>
    public interface IServiceRegistrar : IFluentSyntax
    {
        #region Commented
        /// <summary>
        /// 根据指定的源类型(父类)、目标类(具体实现类)型进行IOC注册
        /// </summary>
        /// <typeparam name="TFrom">源类型(父类)</typeparam>
        /// <typeparam name="TTo">目标类(具体实现类)</typeparam>
        /// <returns>已注册对象实例</returns>
        IServiceRegistrar RegisterServiceType<TFrom, TTo>();
        /// <summary>
        ///  根据指定的源类型(父类)、目标类(具体实现类)和指定的类名称型进行IOC注册
        /// </summary>
        /// <typeparam name="TFrom">源类型(父类)</typeparam>
        /// <typeparam name="TTo">目标类(具体实现类)</typeparam>
        /// <param name="name">指定的类名称</param>
        /// <returns>已注册对象实例</returns>
        IServiceRegistrar RegisterServiceType<TFrom, TTo>(string name);
        /// <summary>
        ///  根据指定的源类型(父类)、目标类(具体实现类)和指定的生命周期进行IOC注册
        /// </summary>
        /// <typeparam name="TFrom">源类型(父类)</typeparam>
        /// <typeparam name="TTo">目标类(具体实现类)</typeparam>
        /// <param name="lifetimeStyle">指定的生命周期</param>
        /// <returns>已注册对象实例</returns>
        IServiceRegistrar RegisterServiceType<TFrom, TTo>(LifetimeStyle lifetimeStyle);
        /// <summary>
        ///  根据指定的源类型(父类)、目标类(具体实现类)和指定的类名称和生命周期进行IOC注册
        /// </summary>
        /// <typeparam name="TFrom">源类型(父类)</typeparam>
        /// <typeparam name="TTo">目标类(具体实现类)</typeparam>
        /// <param name="name">指定的类名称</param>
        /// <param name="lifetimeStyle">指定的生命周期</param>
        /// <returns>已注册对象实例</returns>
        IServiceRegistrar RegisterServiceType<TFrom, TTo>(string name, LifetimeStyle lifetimeStyle);
        /// <summary>
        /// 根据指定的源类型(父类)、目标类(具体实现类)型进行IOC注册
        /// </summary>
        /// <param name="from">源类型(父类)</param>
        /// <param name="to">目标类(具体实现类)</param>
        /// <returns>已注册对象实例</returns>
        IServiceRegistrar RegisterServiceType(Type from, Type to);
        /// <summary>
        ///  根据指定的源类型(父类)、目标类(具体实现类)和指定的类名称型进行IOC注册
        /// </summary>
        /// <param name="from">源类型(父类)</param>
        /// <param name="to">目标类(具体实现类)</param>
        /// <param name="name">指定的类名称</param>
        /// <returns>已注册对象实例</returns>
        IServiceRegistrar RegisterServiceType(Type from, Type to, string name);
        /// <summary>
        ///  根据指定的源类型(父类)、目标类(具体实现类)和指定的生命周期进行IOC注册
        /// </summary>
        /// <param name="from">源类型(父类)</param>
        /// <param name="to">目标类(具体实现类)</param>
        /// <param name="lifetimeStyle">指定的生命周期</param>
        /// <returns>已注册对象实例</returns>
        IServiceRegistrar RegisterServiceType(Type from, Type to, LifetimeStyle lifetimeStyle);
        /// <summary>
        ///  根据指定的源类型(父类)、目标类(具体实现类)和指定的类名称和生命周期进行IOC注册
        /// </summary>
        /// <param name="from">源类型(父类)</param>
        /// <param name="to">目标类(具体实现类)</param>
        /// <param name="name">指定的类名称</param>
        /// <param name="lifetimeStyle">指定的生命周期</param>
        /// <returns>已注册对象实例</returns>
        IServiceRegistrar RegisterServiceType(Type from, Type to, string name, LifetimeStyle lifetimeStyle);

        /// <summary>
        /// Registers the instance as singleton.
        /// </summary>
        /// <typeparam name="TService">Type of the service.</typeparam>
        /// <param name="instance">The instance.</param>
        /// <returns></returns>
        IServiceRegistrar RegisterInstance<TService>(object instance);

        /// <summary>
        /// Registers the instance as singleton.
        /// </summary>
        /// <param name="serviceType">Type of the service.</param>
        /// <param name="instance">The instance.</param>
        /// <returns></returns>
        IServiceRegistrar RegisterInstance(Type serviceType, object instance);

        #endregion
    }
}